﻿<UserControl x:Class="SilverlightPersianDatePickerUsage.TestView2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="clr-namespace:SilverlightPersianDatePickerUsage.ViewModel"
    xmlns:conv="clr-namespace:SilverlightPersianDatePicker.Converters;assembly=SilverlightPersianDatePicker"
    xmlns:dp="clr-namespace:SilverlightPersianDatePicker.Views;assembly=SilverlightPersianDatePicker"              
    mc:Ignorable="d"  FlowDirection="RightToLeft" FontFamily="Tahoma" FontSize="11"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <vm:TestView2ViewModel x:Key="vmTestView2ViewModel" />
        <conv:ToPersianDateConverter x:Key="ToPersianDateConverterConv" />
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" 
          DataContext="{Binding Source={StaticResource vmTestView2ViewModel}}"
          Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="116" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="1"  Margin="5"  Text="نام كاربر"  />
        <TextBlock Grid.Row="2" Margin="5"  Text="اعتبار حساب كاربري تا"  />

        <TextBox Grid.Column="1" Grid.Row="1"
                 Margin="5" Text="{Binding ElementName=listBox1, Path=SelectedItem.Name, Mode=TwoWay}" />
        <dp:PDatePicker                 
                TextBoxWidth="100"
                SelectedDate="{Binding ElementName=listBox1, Path=SelectedItem.AccountValidTo, Mode=TwoWay}"
                Grid.Column="1" 
                Grid.Row="2" 
                Margin="5" TextBoxIsReadOnly="False"
                VerticalAlignment="Top"
                />
        <ListBox 
            Grid.Column="1" 
            Grid.Row="0" 
            Height="100" 
            ItemsSource="{Binding Users}"
            Margin="5"            
            Name="listBox1"                         
            VerticalAlignment="Top">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Name}" Margin="2"/>
                        <TextBlock Text=" - " Margin="2"/>
                        <TextBlock Text="{Binding AccountValidTo, 
                            Converter={StaticResource ToPersianDateConverterConv}}" Margin="2"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>
